﻿using System;
using System.Collections;

namespace ConsoleApp11
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("查找集合中是否含有abc");
            ArrayList list = new ArrayList() { "aaa", "bbb", "abc", 123, 456 };
            int index = list.IndexOf("abc");
            if(index != -1)
            {
                Console.WriteLine("集合中存在abc元素！");
            }
             else
            {
                Console.WriteLine("集合中不存在adc元素");
            }
            Console.WriteLine("将集合中元素下标是偶数的元素添加到另一个集合中");
            ArrayLisa newList = new ArrayLisa();
            for(int i=0;i<list.Count;i=i+2)
            {
                newList.Add(list[i]);
            }
            foreach(var a in newList)
            {
                Console.WriteLine(a);
            }
            Console.WriteLine("在集合中第一个元素的后面任意插入3个元素");
            ArrayList list2 = new ArrayList() { "aaa", "bbb", "abc", 123, 456 };
            ArrayList insert = new ArrayList() { "A", "B", "C" };
            list2.InsertRange(1, insert);
            foreach(var v in list2)
            {
                Console.WriteLine(v);
            }
            Console.WriteLine("将集合中的元素使用Sort方法排序后输出");
            ArrayList list3 = new ArrayList() { "aaa", "bbb", "abc" };
            list3.Sort();
            foreach(var v in list3)
            {
                Console.WriteLine(v);
            }
            Console.WriteLine("使用IConpare的方式排序输出string");

            ArrayList arrayList = new ArrayList() { "fdf", "fgh", "nsd", 264, 452 };
            foreach(var c in arrayList)
            {
                Console.WriteLine(c);
            }
            MyCompare myCompare = new MyCompare();
            arrayList.Sort(myCompare);
            Console.WriteLine();
            foreach(var c in arrayList)
            {
                Console.WriteLine(c);
            }
        }
    }
}
